var express = require('express');
const db = require("../db");
var router = express.Router();

/* GET home page. */
router.get('/', function(req, res, next) {
    res.setHeader('Access-Control-Allow-Origin', '*') // *表示都可以跨域访问
    const sql = "select * from code"
    console.log(sql)
    db.query(sql, (err, data) => {

        if (err) {
            return res.send({code: 400, error: err})
        }
        return res.send({
            code: 200,
            message: 'ok',
            data: data
        })
    })
    // res.send({code: 200, message: 'ok'})
});

module.exports = router;

